Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No test coverage/example for NamedPublicKey #75

Open
mflaxman opened this issue Jun 24, 2021 · 1 comment
Open

No test coverage/example for NamedPublicKey #75

mflaxman opened this issue Jun 24, 2021 · 1 comment
Assignees

Comments

@mflaxman
Copy link
Collaborator

I'm confused how to use NamedPublicKey because they require path/fingerprint info that isn't always available. Is that a mistake?

NamedHDPublicKey objects do require that info, which makes sense. They also have test coverage.

@mflaxman
Copy link
Collaborator Author

mflaxman commented Jun 24, 2021

More specifically, I'm trying to create an unsigned TX object and then use that to create the corresponding PSBT (to sign). I have all the information needed to create the PSBT, but I'm hung up on how to get that into the PSBT without path/fingerprints:

from buidl import *

private_key1 = PrivateKey(secret=8675309)
private_key2 = PrivateKey(secret=8675310)
pubkey1_hex = private_key1.point.sec().hex()
pubkey2_hex = private_key2.point.sec().hex()
redeem_script = RedeemScript(
    [0x52, private_key1.point.sec(), private_key2.point.sec(), 0x52, 0xAE]
)
prev_tx = bytes.fromhex(
    "ded9b3c8b71032d42ea3b2fd5211d75b39a90637f967e637b64dfdb887dd11d7"
)
prev_index = 1
fee_sats = 500
tx_in = TxIn(prev_tx, prev_index)
tx_in_sats = 1000000
amount_sats = tx_in_sats - fee_sats
h160 = decode_base58("mqYz6JpuKukHzPg94y4XNDdPCEJrNkLQcv")
tx_out = TxOut(amount=amount_sats, script_pubkey=P2PKHScriptPubKey(h160))
t = Tx(1, [tx_in], [tx_out], 0, testnet=True, segwit=True)
psbt_obj = PSBT.create(t)

I want to set the named_pubs (as well as redeem_script) on psbt_obj.psbt_ins[0], but I'm not sure how to do that. I can't create a NamedPublicKey object without a root_fingerpint:

NamedPublicKey(x=private_key1.point.x, y=private_key1.point.y)
AttributeError: 'NamedPublicKey' object has no attribute 'root_fingerprint'

@jimmysong any tips would be greatly appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants