Пример #1
0
            if 'multisig p2wsh' == case:
                print(str(resp))

        elif name == 'ConfidentialTransaction.VerifySign':
            resp, txin = get_tx()
            err_list = []
            for txin in req.get('txins', []):
                hash_type = HashType.P2WPKH
                addr = txin.get('address', '')
                desc = txin.get('descriptor', '')
                if desc != '':
                    desc = parse_descriptor(desc, network=Network.LIQUID_V1)
                    addr = desc.data.address
                    hash_type = desc.data.hash_type
                elif addr != '':
                    addr = AddressUtil.parse(addr)
                    hash_type = addr.hash_type

                try:
                    resp.verify_sign(
                        OutPoint(txin['txid'], txin['vout']),
                        addr, hash_type,
                        txin.get('confidentialValueCommitment',
                                 txin.get('amount', 0)))
                except CfdError as err:
                    _dict = {'txid': txin['txid'], 'vout': txin['vout']}
                    _dict['reason'] = err.message
                    err_list.append(_dict)

            success = (len(err_list) == 0)
            resp = {'success': success, 'failTxins': err_list}
Пример #2
0
                resp = AddressUtil.p2wpkh(req['keyData']['hex'],
                                          network=_network)
            elif _hash_type == HashType.P2SH_P2WPKH:
                resp = AddressUtil.p2sh_p2wpkh(req['keyData']['hex'],
                                               network=_network)
            elif _hash_type == HashType.P2SH:
                resp = AddressUtil.p2sh(req['keyData']['hex'],
                                        network=_network)
            elif _hash_type == HashType.P2WSH:
                resp = AddressUtil.p2wsh(req['keyData']['hex'],
                                         network=_network)
            elif _hash_type == HashType.P2SH_P2WSH:
                resp = AddressUtil.p2sh_p2wsh(req['keyData']['hex'],
                                              network=_network)
        elif name == 'Address.GetInfo':
            resp = AddressUtil.parse(req['address'])
        elif name == 'Address.MultisigAddresses':
            resp = AddressUtil.get_multisig_address_list(req['redeemScript'],
                                                         req['hashType'],
                                                         network=_network)
        elif name == 'Address.CreateMultisig':
            resp = AddressUtil.multisig(req['nrequired'],
                                        req['keys'],
                                        req['hashType'],
                                        network=_network)

        elif name == 'Address.FromLockingScript':
            resp = AddressUtil.from_locking_script(req['lockingScript'],
                                                   network=_network)

        else:
Пример #3
0
                                    control_block=txin['controlBlock'],
                                    annex=txin.get('annex', None))

        elif name == 'Transaction.VerifySign':
            err_list = []
            utxos = load_utxo_list(req)
            for txin in req.get('txins', []):
                hash_type = HashType.P2WPKH
                addr = txin.get('address', '')
                desc = txin.get('descriptor', '')
                if desc != '':
                    desc = parse_descriptor(desc)
                    addr = desc.data.address
                    hash_type = desc.data.hash_type
                elif addr != '':
                    addr = AddressUtil.parse(addr)
                    hash_type = addr.hash_type

                try:
                    resp.verify_sign(OutPoint(txin['txid'],
                                              txin['vout']), addr, hash_type,
                                     txin.get('amount', 0), utxos)
                except CfdError as err:
                    _dict = {'txid': txin['txid'], 'vout': txin['vout']}
                    _dict['reason'] = err.message
                    err_list.append(_dict)

            success = (len(err_list) == 0)
            resp = {'success': success, 'failTxins': err_list}

        elif name == 'Transaction.VerifySignature':
Пример #4
0
     psbt = Psbt(req['psbt'], network=req.get(
         'network', Network.MAINNET))
     psbt.sign(privkey=req['privkey'],
               has_grind_r=req.get('hasGrindR', True))
     resp = psbt
 elif name == 'Psbt.AddPsbtData':
     net_type = Network.get(req.get('network', Network.MAINNET))
     psbt = Psbt(req['psbt'], network=net_type)
     for input_data in req.get('inputs', []):
         txin = input_data['txin']
         input = input_data['input']
         utxo = TxOut(0)
         if 'witnessUtxo' in input:
             addr = ''
             if 'address' in input['witnessUtxo']:
                 addr = AddressUtil.parse(
                     input['witnessUtxo']['address'])
             utxo = TxOut(
                 input['witnessUtxo']['amount'],
                 address=addr,
                 locking_script=input['witnessUtxo'].get(
                     'directLockingScript',
                     ''))
         script = '' if 'redeemScript' not in input else Script(
             input['redeemScript'])
         tx = '' if 'utxoFullTx' not in input else Transaction(
             input['utxoFullTx'])
         outpoint = OutPoint(txin['txid'], txin['vout'])
         psbt.add_input(
             outpoint,
             utxo=utxo,
             redeem_script=script,