@@ -1167,8 +1167,7 @@ def withdraw(
1167
1167
self ,
1168
1168
withdrawal_amount : Optional [Union [Ada , Lovelace ]] = None ,
1169
1169
output_amount : Optional [Union [Ada , Lovelace ]] = Lovelace (1000000 ),
1170
- await_confirmation : Optional [bool ] = False ,
1171
- context : Optional [ChainContext ] = None ,
1170
+ ** kwargs ,
1172
1171
) -> str :
1173
1172
"""Withdraw staking rewards.
1174
1173
@@ -1188,31 +1187,20 @@ def withdraw(
1188
1187
if not self .stake_address :
1189
1188
raise ValueError ("This wallet does not have staking keys." )
1190
1189
1191
- context = self ._find_context (context )
1192
-
1193
1190
if not withdrawal_amount :
1194
1191
# automatically detect rewards:
1195
1192
withdrawal_amount = self .withdrawable_amount
1193
+
1194
+ if not withdrawal_amount :
1195
+ raise ValueError ("No rewards to withdraw." )
1196
1196
1197
- builder = TransactionBuilder (context )
1198
- builder .add_input_address (self .address )
1199
- builder .add_output (TransactionOutput (self .address , output_amount .lovelace ))
1200
- builder .withdrawals = Withdrawals (
1201
- {self .stake_address .to_primitive (): withdrawal_amount .lovelace }
1202
- )
1203
-
1204
- signed_tx = builder .build_and_sign (
1205
- [self .signing_key , self .stake_signing_key ], self .address
1197
+ return self .transact (
1198
+ inputs = [self ],
1199
+ outputs = [Output (self , output_amount )],
1200
+ withdrawals = {self : withdrawal_amount },
1201
+ ** kwargs ,
1206
1202
)
1207
1203
1208
- context .submit_tx (signed_tx .to_cbor ())
1209
-
1210
- if await_confirmation :
1211
- confirmed = wait_for_confirmation (str (signed_tx .id ), self .context )
1212
- self .query_utxos ()
1213
-
1214
- return str (signed_tx .id )
1215
-
1216
1204
def mint_tokens (
1217
1205
self ,
1218
1206
to : Union [str , Address ],
0 commit comments