Skip to content

Commit

Permalink
PSBT Field (#7)
Browse files Browse the repository at this point in the history
* PSBT field

* Updated PSBT

* Changes required on json file

* Changes required on json file
  • Loading branch information
tirth2004 authored Aug 29, 2024
1 parent c0dcdc6 commit 69d1e25
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,24 @@
</mat-card-actions>
</mat-card>

<mat-card class="card">
<mat-card-header>
<mat-card-title>Signing PSBT</mat-card-title>
</mat-card-header>
<mat-card-content>
<mat-form-field class="input-full-width" appearance="outline">
<mat-label>Raw PSBT</mat-label>
<input matInput type="text" [(ngModel)]="rawPSBT" />
</mat-form-field>
<div *ngIf="signedPsbtSignature">
<p>Signed PSBT:<br />{{ signedPsbtSignature }}</p>
</div>
</mat-card-content>
<mat-card-actions>
<button mat-flat-button color="primary" (click)="signPsbtAnyAccount(rawPSBT)">Request Signing</button>
</mat-card-actions>
</mat-card>

<mat-card class="card">
<mat-card-header>
<mat-card-title>Signing (JSON)</mat-card-title>
Expand Down Expand Up @@ -303,7 +321,6 @@
</mat-card>
</mat-tab>
<mat-tab label="Atomic Swap">

<div class="actions">
<br />
<p>
Expand Down
16 changes: 16 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ export class AppComponent implements OnInit {
signedTextNetwork?: string;
signedTextValidSignature?: boolean;

// rawPSBT is a Base64-encoded string representing the PSBT
rawPSBT: string =
'70736274ff010052020000000197ad5142d4b313e39d06320d52aa608c06525dd3aad59f3033306cc7dae20ecc0000000000ffffffff01e803000000000000160014d85c2b71d0060b09c9886aeb815e50991dda124d00000000000100e10200000000010179c41695a3be63ad012bdfb3e4fa1e1ed529b546671ee175eca105193940394f0100000000fdffffff02e8030000000000001976a914ad0e5d23994e4aedea78930662c1488ca2544efd88ac4232000000000000160014e3b767040067973106e977f46b9b449fd67f92120247304402200268c49c6e89dd3b8d59b78e35612ec2685730bc471aba3a49edd58d08d089cb02203e12e950cd59f7e0af3da88e33e221247c9ccada7a43ee4910e4d589245c37c80121026b0945d725e12b3c8fe123858bfb4d6da697329b8fbe5e02ee1e0b6ccdf3be79efd42b002206030272524d872070574dc2d183060efb8e691b0d3523e965644384446ec53190f4186c127a852c000080010000800000008000000000000000000000';

signedPsbtSignature?: string;

signedJsonSignature?: string;
signedJsonKey?: string;
signedJsonNetwork?: string;
Expand Down Expand Up @@ -243,6 +249,16 @@ export class AppComponent implements OnInit {
this.signedTextValidSignature = bitcoinMessage.verify(value, result.key, result.response.signature);
}

async signPsbtAnyAccount(value: string) {
const result: any = await this.provider!.request({
method: 'signPsbt',
params: [{ message: value, network: this.provider?.indexer.network }],
});
console.log('Result:', result);

this.signedPsbtSignature = result.response.signature;
}

async signMessageAnyAccountJson(value: string) {
const message = JSON.parse(value);

Expand Down

0 comments on commit 69d1e25

Please sign in to comment.