def test_xinfin_refund_solver(): refund_solver = RefundSolver( xprivate_key=_["xinfin"]["wallet"]["sender"]["root_xprivate_key"], path=_["xinfin"]["wallet"]["sender"]["derivation"]["path"], account=_["xinfin"]["wallet"]["sender"]["derivation"]["account"], change=_["xinfin"]["wallet"]["sender"]["derivation"]["change"], address=_["xinfin"]["wallet"]["sender"]["derivation"]["address"] ) assert isinstance(refund_solver.solve(network=_["xinfin"]["network"]), Wallet)
def test_xinfin_refund_signature(): unsigned_refund_transaction_raw = _["xinfin"]["refund"]["unsigned"][ "transaction_raw"] refund_solver = RefundSolver( xprivate_key=_["xinfin"]["wallet"]["sender"]["root_xprivate_key"], path=_["xinfin"]["wallet"]["sender"]["derivation"]["path"], account=_["xinfin"]["wallet"]["sender"]["derivation"]["account"], change=_["xinfin"]["wallet"]["sender"]["derivation"]["change"], address=_["xinfin"]["wallet"]["sender"]["derivation"]["address"]) signature = Signature(network=_["xinfin"]["network"]).sign( transaction_raw=unsigned_refund_transaction_raw, solver=refund_solver) assert signature.type() == _["xinfin"]["refund"]["signed"]["type"] assert signature.fee() == _["xinfin"]["refund"]["signed"]["fee"] assert signature.hash() == _["xinfin"]["refund"]["signed"]["hash"] assert signature.raw() == _["xinfin"]["refund"]["signed"]["raw"] assert signature.json() == _["xinfin"]["refund"]["signed"]["json"] assert signature.transaction_raw() == clean_transaction_raw( transaction_raw=_["xinfin"]["refund"]["signed"]["transaction_raw"]) refund_signature = RefundSignature(network=_["xinfin"]["network"]).sign( transaction_raw=unsigned_refund_transaction_raw, solver=refund_solver) assert refund_signature.type() == _["xinfin"]["refund"]["signed"]["type"] assert refund_signature.fee() == _["xinfin"]["refund"]["signed"]["fee"] assert refund_signature.hash() == _["xinfin"]["refund"]["signed"]["hash"] assert refund_signature.raw() == _["xinfin"]["refund"]["signed"]["raw"] assert refund_signature.json() == _["xinfin"]["refund"]["signed"]["json"] assert refund_signature.transaction_raw() == clean_transaction_raw( transaction_raw=_["xinfin"]["refund"]["signed"]["transaction_raw"])
def test_xinfin_refund_transaction(): unsigned_refund_transaction = RefundTransaction(network=_["xinfin"]["network"]) unsigned_refund_transaction.build_transaction( address=_["xinfin"]["wallet"]["sender"]["address"], transaction_hash=_["xinfin"]["transaction_hash"] ) assert unsigned_refund_transaction.type() == _["xinfin"]["refund"]["unsigned"]["type"] assert unsigned_refund_transaction.fee() == _["xinfin"]["refund"]["unsigned"]["fee"] assert unsigned_refund_transaction.hash() == _["xinfin"]["refund"]["unsigned"]["hash"] assert unsigned_refund_transaction.raw() == _["xinfin"]["refund"]["unsigned"]["raw"] assert isinstance(unsigned_refund_transaction.json(), dict) assert unsigned_refund_transaction.signature() == _["xinfin"]["refund"]["unsigned"]["signature"] assert isinstance(unsigned_refund_transaction.transaction_raw(), str) signed_refund_transaction = unsigned_refund_transaction.sign( solver=RefundSolver( xprivate_key=_["xinfin"]["wallet"]["sender"]["root_xprivate_key"], path=_["xinfin"]["wallet"]["sender"]["derivation"]["path"], account=_["xinfin"]["wallet"]["sender"]["derivation"]["account"], change=_["xinfin"]["wallet"]["sender"]["derivation"]["change"], address=_["xinfin"]["wallet"]["sender"]["derivation"]["address"] ) ) assert signed_refund_transaction.type() == _["xinfin"]["refund"]["signed"]["type"] assert signed_refund_transaction.fee() == _["xinfin"]["refund"]["signed"]["fee"] assert isinstance(signed_refund_transaction.hash(), str) assert isinstance(signed_refund_transaction.raw(), str) assert isinstance(signed_refund_transaction.json(), dict) assert isinstance(signed_refund_transaction.signature(), dict) assert isinstance(signed_refund_transaction.transaction_raw(), str)
print("Unsigned Refund Transaction Hash:", unsigned_refund_transaction.hash()) print("Unsigned Refund Transaction Main Raw:", unsigned_refund_transaction.raw()) # print("Unsigned Refund Transaction Json:", json.dumps(unsigned_refund_transaction.json(), indent=4)) print("Unsigned Refund Transaction Signature:", json.dumps(unsigned_refund_transaction.signature(), indent=4)) print("Unsigned Refund Transaction Type:", unsigned_refund_transaction.type()) unsigned_refund_transaction_raw: str = unsigned_refund_transaction.transaction_raw( ) print("Unsigned Refund Transaction Raw:", unsigned_refund_transaction_raw) print("=" * 10, "Signed Refund Transaction") # Initialize refund solver refund_solver: RefundSolver = RefundSolver( xprivate_key=sender_wallet.root_xprivate_key(), path=sender_wallet.path()) # Sing unsigned refund transaction signed_refund_transaction: RefundTransaction = unsigned_refund_transaction.sign( solver=refund_solver) print("Signed Refund Transaction Fee:", signed_refund_transaction.fee()) print("Signed Refund Transaction Hash:", signed_refund_transaction.hash()) print("Signed Refund Transaction Main Raw:", signed_refund_transaction.raw()) # print("Signed Refund Transaction Json:", json.dumps(signed_refund_transaction.json(), indent=4)) print("Signed Refund Transaction Signature:", json.dumps(signed_refund_transaction.signature(), indent=4)) print("Signed Refund Transaction Type:", signed_refund_transaction.type()) signed_refund_transaction_raw: str = signed_refund_transaction.transaction_raw( )