mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-21 02:54:20 +01:00
Refactor secret conditions (#350)
* refactor spending conditions and add comments * fix kind enum deserialization
This commit is contained in:
@@ -73,7 +73,6 @@ async def test_htlc_split(wallet1: Wallet, wallet2: Wallet):
|
||||
preimage = "00000000000000000000000000000000"
|
||||
preimage_hash = hashlib.sha256(bytes.fromhex(preimage)).hexdigest()
|
||||
secret = await wallet1.create_htlc_lock(preimage=preimage)
|
||||
# p2pk test
|
||||
_, send_proofs = await wallet1.split_to_send(wallet1.proofs, 8, secret_lock=secret)
|
||||
for p in send_proofs:
|
||||
assert HTLCSecret.deserialize(p.secret).data == preimage_hash
|
||||
@@ -86,7 +85,6 @@ async def test_htlc_redeem_with_preimage(wallet1: Wallet, wallet2: Wallet):
|
||||
preimage = "00000000000000000000000000000000"
|
||||
# preimage_hash = hashlib.sha256(bytes.fromhex(preimage)).hexdigest()
|
||||
secret = await wallet1.create_htlc_lock(preimage=preimage)
|
||||
# p2pk test
|
||||
_, send_proofs = await wallet1.split_to_send(wallet1.proofs, 8, secret_lock=secret)
|
||||
for p in send_proofs:
|
||||
p.witness = HTLCWitness(preimage=preimage).json()
|
||||
@@ -102,7 +100,6 @@ async def test_htlc_redeem_with_wrong_preimage(wallet1: Wallet, wallet2: Wallet)
|
||||
secret = await wallet1.create_htlc_lock(
|
||||
preimage=preimage[:-5] + "11111"
|
||||
) # wrong preimage
|
||||
# p2pk test
|
||||
_, send_proofs = await wallet1.split_to_send(wallet1.proofs, 8, secret_lock=secret)
|
||||
for p in send_proofs:
|
||||
p.witness = HTLCWitness(preimage=preimage).json()
|
||||
@@ -121,7 +118,6 @@ async def test_htlc_redeem_with_no_signature(wallet1: Wallet, wallet2: Wallet):
|
||||
secret = await wallet1.create_htlc_lock(
|
||||
preimage=preimage, hashlock_pubkey=pubkey_wallet1
|
||||
)
|
||||
# p2pk test
|
||||
_, send_proofs = await wallet1.split_to_send(wallet1.proofs, 8, secret_lock=secret)
|
||||
for p in send_proofs:
|
||||
p.witness = HTLCWitness(preimage=preimage).json()
|
||||
@@ -141,8 +137,6 @@ async def test_htlc_redeem_with_wrong_signature(wallet1: Wallet, wallet2: Wallet
|
||||
secret = await wallet1.create_htlc_lock(
|
||||
preimage=preimage, hashlock_pubkey=pubkey_wallet1
|
||||
)
|
||||
|
||||
# p2pk test
|
||||
_, send_proofs = await wallet1.split_to_send(wallet1.proofs, 8, secret_lock=secret)
|
||||
signatures = await wallet1.sign_p2pk_proofs(send_proofs)
|
||||
for p, s in zip(send_proofs, signatures):
|
||||
@@ -166,7 +160,6 @@ async def test_htlc_redeem_with_correct_signature(wallet1: Wallet, wallet2: Wall
|
||||
secret = await wallet1.create_htlc_lock(
|
||||
preimage=preimage, hashlock_pubkey=pubkey_wallet1
|
||||
)
|
||||
# p2pk test
|
||||
_, send_proofs = await wallet1.split_to_send(wallet1.proofs, 8, secret_lock=secret)
|
||||
|
||||
signatures = await wallet1.sign_p2pk_proofs(send_proofs)
|
||||
@@ -192,7 +185,6 @@ async def test_htlc_redeem_hashlock_wrong_signature_timelock_correct_signature(
|
||||
locktime_seconds=5,
|
||||
locktime_pubkey=pubkey_wallet1,
|
||||
)
|
||||
# p2pk test
|
||||
_, send_proofs = await wallet1.split_to_send(wallet1.proofs, 8, secret_lock=secret)
|
||||
|
||||
signatures = await wallet1.sign_p2pk_proofs(send_proofs)
|
||||
@@ -226,7 +218,6 @@ async def test_htlc_redeem_hashlock_wrong_signature_timelock_wrong_signature(
|
||||
locktime_seconds=5,
|
||||
locktime_pubkey=pubkey_wallet1,
|
||||
)
|
||||
# p2pk test
|
||||
_, send_proofs = await wallet1.split_to_send(wallet1.proofs, 8, secret_lock=secret)
|
||||
|
||||
signatures = await wallet1.sign_p2pk_proofs(send_proofs)
|
||||
|
||||
Reference in New Issue
Block a user