@@ -2019,6 +2019,12 @@ func (r *rpcServer) FundVirtualPsbt(ctx context.Context,
20192019 req * wrpc.FundVirtualPsbtRequest ) (* wrpc.FundVirtualPsbtResponse ,
20202020 error ) {
20212021
2022+ coinSelectType , err := unmarshalCoinSelectType (req .CoinSelectType )
2023+ if err != nil {
2024+ return nil , fmt .Errorf ("error parsing coin select type: %w" ,
2025+ err )
2026+ }
2027+
20222028 var fundedVPkt * tapfreighter.FundedVPacket
20232029 switch {
20242030 case req .GetPsbt () != nil :
@@ -2040,9 +2046,8 @@ func (r *rpcServer) FundVirtualPsbt(ctx context.Context,
20402046 "recipients: %w" , err )
20412047 }
20422048
2043- fundedVPkt , err = r .cfg .AssetWallet .FundPacket (
2044- ctx , desc , vPkt ,
2045- )
2049+ desc .CoinSelectType = coinSelectType
2050+ fundedVPkt , err = r .cfg .AssetWallet .FundPacket (ctx , desc , vPkt )
20462051 if err != nil {
20472052 return nil , fmt .Errorf ("error funding packet: %w" , err )
20482053 }
@@ -2073,7 +2078,9 @@ func (r *rpcServer) FundVirtualPsbt(ctx context.Context,
20732078 return nil , fmt .Errorf ("no recipients specified" )
20742079 }
20752080
2076- fundedVPkt , err = r .cfg .AssetWallet .FundAddressSend (ctx , addr )
2081+ fundedVPkt , err = r .cfg .AssetWallet .FundAddressSend (
2082+ ctx , coinSelectType , addr ,
2083+ )
20772084 if err != nil {
20782085 return nil , fmt .Errorf ("error funding address send: " +
20792086 "%w" , err )
@@ -2117,6 +2124,26 @@ func (r *rpcServer) FundVirtualPsbt(ctx context.Context,
21172124 return response , nil
21182125}
21192126
2127+ // unmarshalCoinSelectType converts an RPC select type into a native one.
2128+ func unmarshalCoinSelectType (
2129+ coinSelectType wrpc.CoinSelectType ) (tapsend.CoinSelectType , error ) {
2130+
2131+ switch coinSelectType {
2132+ case wrpc .CoinSelectType_COIN_SELECT_DEFAULT :
2133+ return tapsend .DefaultCoinSelectType , nil
2134+
2135+ case wrpc .CoinSelectType_COIN_SELECT_BIP86_ONLY :
2136+ return tapsend .Bip86Only , nil
2137+
2138+ case wrpc .CoinSelectType_COIN_SELECT_SCRIPT_TREES_ALLOWED :
2139+ return tapsend .ScriptTreesAllowed , nil
2140+
2141+ default :
2142+ return 0 , fmt .Errorf ("unknown coin select type: %d" ,
2143+ coinSelectType )
2144+ }
2145+ }
2146+
21202147// SignVirtualPsbt signs the inputs of a virtual transaction and prepares the
21212148// commitments of the inputs and outputs.
21222149func (r * rpcServer ) SignVirtualPsbt (ctx context.Context ,
0 commit comments