@@ -1201,23 +1201,21 @@ impl SharedOwnedOutput {
1201
1201
pub ( super ) enum OutputOwned {
1202
1202
/// Belongs to a single party -- controlled exclusively and fully belonging to a single party
1203
1203
Single ( TxOut ) ,
1204
- /// Output with shared control, but fully belonging to local node
1205
- SharedControlFullyOwned ( TxOut ) ,
1206
- /// Output with shared control and joint ownership
1204
+ /// Output with shared control and value split between the two ends (or fully at one side)
1207
1205
Shared ( SharedOwnedOutput ) ,
1208
1206
}
1209
1207
1210
1208
impl OutputOwned {
1211
1209
pub fn tx_out ( & self ) -> & TxOut {
1212
1210
match self {
1213
- OutputOwned :: Single ( tx_out) | OutputOwned :: SharedControlFullyOwned ( tx_out ) => tx_out,
1211
+ OutputOwned :: Single ( tx_out) => tx_out,
1214
1212
OutputOwned :: Shared ( output) => & output. tx_out ,
1215
1213
}
1216
1214
}
1217
1215
1218
1216
fn into_tx_out ( self ) -> TxOut {
1219
1217
match self {
1220
- OutputOwned :: Single ( tx_out) | OutputOwned :: SharedControlFullyOwned ( tx_out ) => tx_out,
1218
+ OutputOwned :: Single ( tx_out) => tx_out,
1221
1219
OutputOwned :: Shared ( output) => output. tx_out ,
1222
1220
}
1223
1221
}
@@ -1229,30 +1227,25 @@ impl OutputOwned {
1229
1227
fn is_shared ( & self ) -> bool {
1230
1228
match self {
1231
1229
OutputOwned :: Single ( _) => false ,
1232
- OutputOwned :: SharedControlFullyOwned ( _) => true ,
1233
1230
OutputOwned :: Shared ( _) => true ,
1234
1231
}
1235
1232
}
1236
1233
1237
1234
fn local_value ( & self , local_role : AddingRole ) -> u64 {
1238
1235
match self {
1239
- OutputOwned :: Single ( tx_out) | OutputOwned :: SharedControlFullyOwned ( tx_out) => {
1240
- match local_role {
1241
- AddingRole :: Local => tx_out. value . to_sat ( ) ,
1242
- AddingRole :: Remote => 0 ,
1243
- }
1236
+ OutputOwned :: Single ( tx_out) => match local_role {
1237
+ AddingRole :: Local => tx_out. value . to_sat ( ) ,
1238
+ AddingRole :: Remote => 0 ,
1244
1239
} ,
1245
1240
OutputOwned :: Shared ( output) => output. local_owned ,
1246
1241
}
1247
1242
}
1248
1243
1249
1244
fn remote_value ( & self , local_role : AddingRole ) -> u64 {
1250
1245
match self {
1251
- OutputOwned :: Single ( tx_out) | OutputOwned :: SharedControlFullyOwned ( tx_out) => {
1252
- match local_role {
1253
- AddingRole :: Local => 0 ,
1254
- AddingRole :: Remote => tx_out. value . to_sat ( ) ,
1255
- }
1246
+ OutputOwned :: Single ( tx_out) => match local_role {
1247
+ AddingRole :: Local => 0 ,
1248
+ AddingRole :: Remote => tx_out. value . to_sat ( ) ,
1256
1249
} ,
1257
1250
OutputOwned :: Shared ( output) => output. remote_owned ( ) ,
1258
1251
}
@@ -1516,12 +1509,9 @@ impl InteractiveTxConstructor {
1516
1509
for output in & outputs_to_contribute {
1517
1510
let new_output = match output {
1518
1511
OutputOwned :: Single ( _tx_out) => None ,
1519
- OutputOwned :: SharedControlFullyOwned ( tx_out) => {
1520
- Some ( ( tx_out. script_pubkey . clone ( ) , tx_out. value . to_sat ( ) ) )
1521
- } ,
1522
1512
OutputOwned :: Shared ( output) => {
1523
1513
// Sanity check
1524
- if output. local_owned >= output. tx_out . value . to_sat ( ) {
1514
+ if output. local_owned > output. tx_out . value . to_sat ( ) {
1525
1515
return Err ( AbortReason :: InvalidLowFundingOutputValue ) ;
1526
1516
}
1527
1517
Some ( ( output. tx_out . script_pubkey . clone ( ) , output. local_owned ) )
@@ -2138,7 +2128,9 @@ mod tests {
2138
2128
2139
2129
/// Generate a single output that is the funding output
2140
2130
fn generate_output ( output : & TestOutput ) -> Vec < OutputOwned > {
2141
- vec ! [ OutputOwned :: SharedControlFullyOwned ( generate_txout( output) ) ]
2131
+ let txout = generate_txout ( output) ;
2132
+ let value = txout. value . to_sat ( ) ;
2133
+ vec ! [ OutputOwned :: Shared ( SharedOwnedOutput :: new( txout, value) ) ]
2142
2134
}
2143
2135
2144
2136
/// Generate a single P2WSH output that is the funding output
@@ -2707,7 +2699,8 @@ mod tests {
2707
2699
. collect :: < Vec < ( TxIn , TransactionU16LenLimited ) > > ( ) ;
2708
2700
let our_contributed = 110_000 ;
2709
2701
let txout = TxOut { value : Amount :: from_sat ( 128_000 ) , script_pubkey : ScriptBuf :: new ( ) } ;
2710
- let outputs = vec ! [ OutputOwned :: SharedControlFullyOwned ( txout) ] ;
2702
+ let value = txout. value . to_sat ( ) ;
2703
+ let outputs = vec ! [ OutputOwned :: Shared ( SharedOwnedOutput :: new( txout, value) ) ] ;
2711
2704
let funding_feerate_sat_per_1000_weight = 3000 ;
2712
2705
2713
2706
let total_inputs: u64 = input_prevouts. iter ( ) . map ( |o| o. value . to_sat ( ) ) . sum ( ) ;
0 commit comments