Problem
There is an API asymmetry between the two withdrawal methods in rs-sdk:
-
WithdrawFromIdentity::withdraw() accepts Option<Address> and converts internally to CoreScript via CoreScript::new(address.script_pubkey()) (withdraw_from_identity.rs)
-
WithdrawAddressFunds::withdraw_address_funds() requires CoreScript directly — there is no Address convenience (address_credit_withdrawal.rs)
This asymmetry propagates to the WASM SDK / evo-sdk layer:
identities.creditWithdrawal() accepts a toAddress: string
addresses.withdraw() requires an outputScript: CoreScript object, forcing users to manually construct a CoreScript via CoreScript.newP2PKH(keyHashBytes) or CoreScript.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 — WithdrawAddressFunds trait (accepts CoreScript)
packages/rs-sdk/src/platform/transition/withdraw_from_identity.rs — WithdrawFromIdentity trait (accepts Address, converts to CoreScript at line 50)
packages/wasm-sdk/src/state_transitions/addresses.rs — WASM AddressFundsWithdrawOptions (requires CoreScript)
packages/wasm-sdk/src/state_transitions/identity.rs — WASM IdentityCreditWithdrawalOptions (accepts toAddress: string)
packages/wasm-dpp2/src/core_script.rs — CoreScriptWasm (has toAddress() but no fromAddress())
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 toWithdrawAddressFunds(either a second trait method or modify the existing signature to acceptAddressand convert internally, matching the pattern inWithdrawFromIdentity).Then update the WASM SDK's
AddressFundsWithdrawOptionsto accept an optionaltoAddress: string(likeIdentityCreditWithdrawalOptionsalready does), parsing it withAddress::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())