-
Notifications
You must be signed in to change notification settings - Fork 47
Description
Problem
There is an API asymmetry between the two withdrawal methods in rs-sdk:
-
WithdrawFromIdentity::withdraw()acceptsOption<Address>and converts internally toCoreScriptviaCoreScript::new(address.script_pubkey())(withdraw_from_identity.rs) -
WithdrawAddressFunds::withdraw_address_funds()requiresCoreScriptdirectly — there is noAddressconvenience (address_credit_withdrawal.rs)
This asymmetry propagates to the WASM SDK / evo-sdk layer:
identities.creditWithdrawal()accepts atoAddress: stringaddresses.withdraw()requires anoutputScript: CoreScriptobject, forcing users to manually construct aCoreScriptviaCoreScript.newP2PKH(keyHashBytes)orCoreScript.newP2SH(scriptHashBytes)
Proposed Solution
Add an Address-accepting convenience to WithdrawAddressFunds (either a second trait method or modify the existing signature to accept Address and convert internally, matching the pattern in WithdrawFromIdentity).
Then update the WASM SDK's AddressFundsWithdrawOptions to accept an optional toAddress: string (like IdentityCreditWithdrawalOptions already does), parsing it with Address::from_str().
Relevant Files
packages/rs-sdk/src/platform/transition/address_credit_withdrawal.rs—WithdrawAddressFundstrait (acceptsCoreScript)packages/rs-sdk/src/platform/transition/withdraw_from_identity.rs—WithdrawFromIdentitytrait (acceptsAddress, converts toCoreScriptat line 50)packages/wasm-sdk/src/state_transitions/addresses.rs— WASMAddressFundsWithdrawOptions(requiresCoreScript)packages/wasm-sdk/src/state_transitions/identity.rs— WASMIdentityCreditWithdrawalOptions(acceptstoAddress: string)packages/wasm-dpp2/src/core_script.rs—CoreScriptWasm(hastoAddress()but nofromAddress())