コード例 #1
0
ファイル: main.py プロジェクト: commerceblock/pymainstay
def verify():
    args = Record()
    args.service_url = 'https://mainstay.xyz'
    args.bitcoin_node = 'https://api.blockcypher.com/v1/btc/main/txs/'

    data = flask.request.get_json()

    slot_number = data.get('slotNumber')
    try:
        args.slot = int(slot_number) if slot_number else -1
    except:
        return json.dumps({"Error": "Please input right slot number"})

    args.commitment = data.get('commitment')

    response_data = {}

    result = verify_command(args)

    if result:
        if ('confirmed' in result and not result.get('confirmed')) or not result[0]:
            response_data['commitment'] = str(result[1])
        else:
            response_data['commitment'] = args.commitment
            response_data['slot'] = args.slot
            response_data['txid'] = result[1].split()[8]
            response_data['bitcoin_block'] = result[2].split()[3]
            response_data['height'] = result[2].split()[5]
            response_data['date'] = str(datetime.datetime.strptime(result[2].split()[7], '%Y-%m-%dT%H:%M:%SZ'))
        return response_data
    else:
        response_data['commitment'] = "Unknown"

    return response_data
コード例 #2
0
    def test_validproof(self):

        raw_args = []
        raw_args.append('verify')
        raw_args.append('-f')
        raw_args.append('test_sequence_1.msp')
        raw_args.append('-i')
        raw_args.append('5222ffe08bfd4ca0db30d261b2d54d0b6e3faed5276be422e5e6ac32c450ccd7')

        args = mst.args.parse_msc_args(raw_args)
        out = cm.verify_command(args)
        self.assertTrue(out)
コード例 #3
0
    def test_invalidproof(self):

        raw_args = []
        raw_args.append('verify')
        raw_args.append('-f')
        raw_args.append('test_sequence_3.msp')

        args = mst.args.parse_msc_args(raw_args)
        try:
            out = cm.verify_command(args)
        except:
            out = False
        self.assertFalse(out)
コード例 #4
0
    def test_invalidlistproof(self):

        raw_args = []
        raw_args.append('verify')
        raw_args.append('-f')
        raw_args.append('test_sequence_2.msp')
        raw_args.append('-l')
        raw_args.append('2ec91e4da17e991b2b11d4de76b43fe9a550ce2a59d8b2e0c9dbebc8f5aead5a,2e93d25081d0c14cfe0d556e0c5c0e4b6b109d50e61f0caa16da33b064c3ac87,50270593506e065e127e8abfa05205337163ebdeeb1ae45428af8b02cda761c9')

        args = mst.args.parse_msc_args(raw_args)

        out = cm.verify_command(args)
        self.assertFalse(out)
コード例 #5
0
    def test_docsequenceinvalid(self):

        cwd = os.getcwd()

        raw_args = []
        raw_args.append('verify')
        raw_args.append('-f')
        raw_args.append('test_sequence_1.msp')
        raw_args.append('-d')
        raw_args.append(cwd+'/files2/')

        args = mst.args.parse_msc_args(raw_args)
        try:
            out = cm.verify_command(args)
        except:
            out = False
        self.assertFalse(out)