mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-04 21:36:45 +00:00
further payjoin tweaks
This commit is contained in:
parent
bcf6f77340
commit
1b220c72ea
3 changed files with 16 additions and 13 deletions
|
@ -32,10 +32,14 @@ import org.controlsfx.validation.ValidationResult;
|
|||
import org.controlsfx.validation.ValidationSupport;
|
||||
import org.controlsfx.validation.Validator;
|
||||
import org.controlsfx.validation.decoration.StyleClassValidationDecoration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DevicePane extends TitledDescriptionPane {
|
||||
private static final Logger log = LoggerFactory.getLogger(DevicePane.class);
|
||||
|
||||
private final DeviceOperation deviceOperation;
|
||||
private final Wallet wallet;
|
||||
private final PSBT psbt;
|
||||
|
@ -467,6 +471,7 @@ public class DevicePane extends TitledDescriptionPane {
|
|||
});
|
||||
signPSBTService.setOnFailed(workerStateEvent -> {
|
||||
setError("Signing Error", signPSBTService.getException().getMessage());
|
||||
log.error("Signing Error: " + signPSBTService.getException().getMessage());
|
||||
signButton.setDisable(false);
|
||||
});
|
||||
setDescription("Signing...");
|
||||
|
|
|
@ -35,24 +35,17 @@ public class Payjoin {
|
|||
public Payjoin(BitcoinURI payjoinURI, Wallet wallet, PSBT psbt) {
|
||||
this.payjoinURI = payjoinURI;
|
||||
this.wallet = wallet;
|
||||
this.psbt = psbt.getPublicCopy();
|
||||
this.psbt = psbt;
|
||||
|
||||
for(PSBTInput psbtInput : this.psbt.getPsbtInputs()) {
|
||||
for(PSBTInput psbtInput : psbt.getPsbtInputs()) {
|
||||
if(psbtInput.getUtxo() == null) {
|
||||
throw new IllegalArgumentException("Original PSBT for payjoin transaction must have non_witness_utxo or witness_utxo fields for all inputs");
|
||||
}
|
||||
if(!psbtInput.getDerivedPublicKeys().isEmpty()) {
|
||||
throw new IllegalArgumentException("Original PSBT for payjoin transaction must have no derived public keys for all inputs");
|
||||
}
|
||||
}
|
||||
|
||||
if(!this.psbt.isFinalized()) {
|
||||
if(!psbt.isFinalized()) {
|
||||
throw new IllegalArgumentException("Original PSBT for payjoin transaction must be finalized");
|
||||
}
|
||||
|
||||
if(!this.psbt.getExtendedPublicKeys().isEmpty()) {
|
||||
throw new IllegalArgumentException("Original PSBT for payjoin transaction must have no global xpubs");
|
||||
}
|
||||
}
|
||||
|
||||
public PSBT requestPayjoinPSBT(boolean allowOutputSubstitution) throws PayjoinReceiverException {
|
||||
|
@ -67,7 +60,7 @@ public class Payjoin {
|
|||
}
|
||||
|
||||
try {
|
||||
String base64Psbt = psbt.toBase64String();
|
||||
String base64Psbt = psbt.getPublicCopy().toBase64String();
|
||||
|
||||
String appendQuery = "v=1";
|
||||
int changeOutputIndex = getChangeOutputIndex();
|
||||
|
@ -175,6 +168,7 @@ public class Payjoin {
|
|||
proposedPSBTInput.setWitnessUtxo(originalPSBTInput.getWitnessUtxo());
|
||||
// We fill up information we had on the signed PSBT, so we can sign it.
|
||||
proposedPSBTInput.getDerivedPublicKeys().putAll(originalPSBTInput.getDerivedPublicKeys());
|
||||
proposedPSBTInput.getProprietary().putAll(originalPSBTInput.getProprietary());
|
||||
proposedPSBTInput.setRedeemScript(originalPSBTInput.getFinalScriptSig().getFirstNestedScript());
|
||||
proposedPSBTInput.setWitnessScript(originalPSBTInput.getFinalScriptWitness().getWitnessScript());
|
||||
proposedPSBTInput.setSigHash(originalPSBTInput.getSigHash());
|
||||
|
@ -251,6 +245,7 @@ public class Payjoin {
|
|||
PSBTOutput originalPSBTOutput = originalOutput.getValue();
|
||||
// We fill up information we had on the signed PSBT, so we can sign it.
|
||||
proposedPSBTOutput.getDerivedPublicKeys().putAll(originalPSBTOutput.getDerivedPublicKeys());
|
||||
proposedPSBTOutput.getProprietary().putAll(originalPSBTOutput.getProprietary());
|
||||
proposedPSBTOutput.setRedeemScript(originalPSBTOutput.getRedeemScript());
|
||||
proposedPSBTOutput.setWitnessScript(originalPSBTOutput.getWitnessScript());
|
||||
}
|
||||
|
@ -263,6 +258,10 @@ public class Payjoin {
|
|||
throw new PayjoinReceiverException("Some of our outputs are not included in the proposal");
|
||||
}
|
||||
}
|
||||
|
||||
//Add global pubkey map for signing
|
||||
proposal.getExtendedPublicKeys().putAll(psbt.getExtendedPublicKeys());
|
||||
proposal.getGlobalProprietary().putAll(psbt.getGlobalProprietary());
|
||||
}
|
||||
|
||||
private int getChangeOutputIndex() {
|
||||
|
|
|
@ -376,7 +376,6 @@ public class HeadersController extends TransactionFormController implements Init
|
|||
broadcastButtonBox.setVisible(false);
|
||||
|
||||
if(headersForm.getBlockTransaction() != null) {
|
||||
blockchainForm.setVisible(true);
|
||||
updateBlockchainForm(headersForm.getBlockTransaction(), AppController.getCurrentBlockHeight());
|
||||
} else if(headersForm.getPsbt() != null) {
|
||||
PSBT psbt = headersForm.getPsbt();
|
||||
|
@ -481,6 +480,7 @@ public class HeadersController extends TransactionFormController implements Init
|
|||
}
|
||||
|
||||
private void updateBlockchainForm(BlockTransaction blockTransaction, Integer currentHeight) {
|
||||
signaturesForm.setVisible(false);
|
||||
blockchainForm.setVisible(true);
|
||||
|
||||
if(Sha256Hash.ZERO_HASH.equals(blockTransaction.getBlockHash()) && blockTransaction.getHeight() == 0 && headersForm.getSigningWallet() == null) {
|
||||
|
@ -1013,7 +1013,6 @@ public class HeadersController extends TransactionFormController implements Init
|
|||
BlockTransaction blockTransaction = transactionMap.get(txid);
|
||||
if(blockTransaction != null) {
|
||||
headersForm.setBlockTransaction(blockTransaction);
|
||||
signaturesForm.setVisible(false);
|
||||
updateBlockchainForm(blockTransaction, AppController.getCurrentBlockHeight());
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue